class DesUtil
  def self.encrypt(pass="kEHrDooxWHCWtfeSxvDvgqZq", value)
    des = OpenSSL::Cipher.new 'des-cbc'
    des.encrypt
    des.key = pass
    des.iv = [1, -1, 1, -1, 1, -1, 1, -1].pack 'C*'
    cipher = des.update(value) + des.final
    Base64.encode64(cipher)
  end

  def self.decrypt(pass="kEHrDooxWHCWtfeSxvDvgqZq", encrypted)
    des = OpenSSL::Cipher.new 'des-cbc'
    des.decrypt
    des.key = pass
    des.iv = [1, -1, 1, -1, 1, -1, 1, -1].pack 'C*'
    plain_text = ""
    plain_text << des.update(Base64.decode64(encrypted))
    plain_text << des.final
    return plain_text
  end
end